package com.cet.algorithm.链表;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2022-03-11 11:44
 **/

public class ListNode {

    int val;

    ListNode next;

    ListNode() {}

    ListNode(int val) { this.val = val; }

    ListNode(int val, ListNode next) { this.val = val; this.next = next; }

    public static ListNode init(int... a) {
        ListNode dummy = new ListNode();
        ListNode current = dummy;
        for (int i : a) {
            current.next = new ListNode(i);
            current = current.next;
        }
        return dummy.next;
    }

    @Override
    public String toString() {
        return "ListNode{" +
                "val=" + val +
                ", next=" + next +
                '}';
    }
}

